/**
 * bipush指令从操作数中获取一个byte型整数，扩展成int型，然后推入栈顶。
 * sipush指令从操作数中获取一个short型整数，扩展成int型，然后推入栈顶
 * User: Zhikang.Peng
 * Date: 2018/04/10 11:27
 */
package constants

import (
	"gitee.com/thghh/jvmgo/instructions/base"
	"gitee.com/thghh/jvmgo/rtda"
)

// push byte
type BIPUSH struct{ value int8 }

func (self *BIPUSH) FetchOperands(reader *base.BytecodeReader) {
	self.value = reader.ReadInt8()
}

func (self *BIPUSH) Execute(frame *rtda.Frame) {
	i := int32(self.value)
	frame.OperandStack().PushInt(i)
}

// push short
type SIPUSH struct{ value int16 }

func (self *SIPUSH) FetchOperands(reader *base.BytecodeReader) {
	self.value = reader.ReadInt16()
}

func (self *SIPUSH) Execute(frame *rtda.Frame) {
	i := int32(self.value)
	frame.OperandStack().PushInt(i)
}
